<?php
include('../includes/config.inc');
include('../includes/variables.inc');
mysql_connect($DB_HOST, $DB_VIEW_USER, $DB_VIEW_USER_PASS);
mysql_select_db($DB_NAME);

include ('../includes/class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('../includes/fonts/Helvetica.afm');

$sql = "SELECT * FROM `album` WHERE `status`='".mysql_real_escape_string($_POST['status'])."' AND `category`='".mysql_real_escape_string($_POST['category'])."' ORDER BY TRIM(LEADING 'the ' FROM LOWER(`artist`)) ASC ";
$query = mysql_query($sql);
while ($CD = mysql_fetch_array($query))
{
//		array('main' => ($CD['artist'] . ' --  <i>' . $CD['title'] . '</i>'), 'slotno' => ($CD['slot']))

$data[] = array(
	'Artist' => $CD['artist'],
	'Album'=> $CD['title'],
	'Slot' => "{$CD["slot"]}{$CD["multi"]}"
);
}
$Heading = $_POST['category'] . ' CD List';
$pdf->ezTable($data, "", "{$Heading}"); /*, 
	   array('showHeadings'=>0, 'shaded'=>0, 'width'=>260, 'cols' => 
		  array('main'=>
			 array('width'=>230,'justification'=>'left')
		  ), 
		  array('slotno'=> 
		array('width'=>30,'justification'=>'right')
		  ) 
		)
		);

//		$description = array(
//		array($pdfResult['review'])
//		);
//		$pdf->ezTable($description,'','',array('width'=>260, 'justification'=>'right','showHeadings'=>0));

/*		$GoodCuts = 'Good Cuts: ';
		$CutsQuery = mysql_query("SELECT * FROM `track` WHERE (`cddbid`='".$pdfResult['cddbid']."') AND (`virtue`>'2') ");
		while($pdfTrackResult = mysql_fetch_array($CutsQuery)) {
		   if ($pdfTrackResult[virtue] >= 4) $GoodCuts = $GoodCuts . '<b>';
		   if ($pdfTrackResult[virtue] >= 5) $GoodCuts = $GoodCuts . '<u>';
		   $GoodCuts = $GoodCuts . $pdfTrackResult[trackno];
		   if ($pdfTrackResult[virtue] >= 5) $GoodCuts = $GoodCuts . '</u>';
		   if ($pdfTrackResult[virtue] >= 4) $GoodCuts = $GoodCuts . '</b>';
		   $GoodCuts = $GoodCuts . ' ';
		}
		$GoodCuts = array(array($GoodCuts)); 
		$pdf->ezTable($GoodCuts,'','',array('width'=>260, 'justification'=>'left','showHeadings'=>0));

		$AvoidCuts = 'Avoid: ';
		$CutsQuery = mysql_query("SELECT * FROM `track` WHERE (`cddbid`='".$pdfResult['cddbid']."') AND (`virtue`<'2') ");
		while($pdfTrackResult = mysql_fetch_array($CutsQuery)) {
		  $AvoidCuts = $AvoidCuts . $pdfTrackResult[trackno] . ' ';
		}
		if ($AvoidCuts === 'Avoid: ') $AvoidCuts = 'Avoid: none (all clean)';
		$AvoidCuts = array(array($AvoidCuts)); 
		$pdf->ezTable($AvoidCuts,'','',array('width'=>260, 'justification'=>'left','showHeadings'=>0));
		$pdf->ezText(' ');
	}
*/
//}
$pdf->ezStream();
?>